///Implementation of Groovey renderer list class

#include "grenderer_list.hpp"

GRenderer_List::GRenderer_List()
{
}/////////////////////////Renderer List constructor

int GRenderer_List::addRenderer(GRenderer& Rend)
{
    render_set.push_back(Rend);
}/////////////////////////addRenderer()

int GRenderer_List::getState(const int Rend_dex)
{
    return 0; ///for now, we don't care, but as this stuff gets more complicated, we will care more
}/////////////////////////getState()

GRenderer& GRenderer_List::operator[](const int Index)
{
	std::list<GRenderer>::iterator i = render_set.begin();
    for (int k = 0; k < Index; i++);
    return *i;
}/////////////////////////overloaded [] index operator

void GRenderer_List::render(GParticle_List& GPList)
{
    ///Get access to rendering
    boost::mutex::scoped_lock lk(GPList.renderLock());
    
    if (GPList.Rendered()){///if the list is rendered
	   (GPList.getRdyToRender()).wait(lk);///wait until it needs another render
    }
    
    for (std::list<GRenderer>::iterator i = render_set.begin(); i != render_set.end(); i++){
        i->Render(GPList);
    }
    
    GPList.renderOpen();
    
}/////////////////////////Render routine
